package com.guigu.tms.commons.order.entity;

import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;

import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;

/**
 * <p>
 * 订单
 * </p>
 *
 * @author zwj
 * @since 2022-09-27
 */
@TableName("pd_order")
@Data
public class Order implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * id
     */
    @TableId(value = "id", type = IdType.AUTO)
    private Integer id;


    /**
     * 订单编号
     */
    private String orderId;

    /**
     * 订单类型，1为同城订单，2为城际订单
     */
    private Integer orderType;

    /**
     * 取件类型，1为网点自寄，2为上门取件
     */
    private Integer pickupType;

    /**
     * 下单时间
     */
    @TableField(fill = FieldFill.INSERT)
    private LocalDateTime createTime;

    /**
     * 客户id
     */
    private String memberId;

    /**
     * 收件人省份id
     */
    private String receiverProvinceId;

    /**
     * 收件人城市id
     */
    private String receiverCityId;

    /**
     * 收件人区县id
     */
    private String receiverCountyId;

    /**
     * 收件人详细地址
     */
    private String receiverAddress;

    /**
     * 收件人地址id
     */
    private String receiverAddressId;

    /**
     * 收件人姓名
     */
    private String receiverName;

    /**
     * 收件人电话
     */
    private String receiverPhone;

    /**
     * 发件人省份id
     */
    private String senderProvinceId;

    /**
     * 发件人城市id
     */
    private String senderCityId;

    /**
     * 发件人区县id
     */
    private String senderCountyId;

    /**
     * 发件人详细地址
     */
    private String senderAddress;

    /**
     * 发件人地址id
     */
    private String senderAddressId;

    /**
     * 发件人姓名
     */
    private String senderName;

    /**
     * 发件人电话
     */
    private String senderPhone;

    /**
     * 订单当前所属网点
     */
    private String currentAgencyId;

    /**
     * 付款方式,1.预结2到付
     */
    private Integer paymentMethod;

    /**
     * 付款状态,1.未付2已付
     */
    private Integer paymentStatus;

    /**
     * 金额
     */
    private BigDecimal amount;

    /**
     * 预计到达时间
     */
//    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")

    private LocalDateTime estimatedArrivalTime;

    /**
     * 距离，单位：公里
     */
    private BigDecimal distance;

    /**
     * 订单状态 从1开始 ['待取件','网点自寄','已取件','待发车','运输中','待派送','派送中','已签收','拒签','已取消']
     */
    private Integer status;



    //货物信息
    @TableField(exist = false)
    private OrderCargo orderCargo;
    //订单位置信息
    @TableField(exist = false)
    private OrderLocation orderLocation;
    //寄件人全地址
    @TableField(exist = false)
    private String senderFullAddress;
    //收件人全地址
    @TableField(exist = false)
    private String receiverFullAddress;

    @TableField(exist = false)
    private TransportOrder transportOrder;

    @TableField(exist = false)
    private TaskPickupDispatch taskPickupDispatch;

    @TableField(exist = false)
    private String startAgencyId;

    @TableField(exist = false)
    private String endAgencyId;

    public String getSenderFullAddress() {
        return this.senderProvinceId+this.senderCityId+this.senderCountyId+senderAddress;
    }

    public void setSenderFullAddress(String senderFullAddress) {
        this.senderFullAddress = senderFullAddress;
    }

    public String getReceiverFullAddress() {
        return this.receiverProvinceId+this.receiverCityId+this.receiverCountyId+receiverAddress;
    }

    public void setReceiverFullAddress(String receiverFullAddress) {
        this.receiverFullAddress = receiverFullAddress;
    }

    public String groupBy(){
        return this.startAgencyId+"#"+this.endAgencyId+"#"+currentAgencyId;
    }

}
